#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "share.h"

#define UART0_PORT 			0			    
#define IOT_UART_PORT   	0				// cat1-m0 uart
#define UART1_PORT 			1			    
#define C485_UART_PORT  	1   			// define 485 protocol's uart port
#define UART2_PORT 			2
#if(ZQ_COMM_PLATFORM == 485)			    
    #define DBG_UART_PORT   2				// 让出485 port, dowload/debug log uart
#else
    #define DBG_UART_PORT   1				// dowload/debug log uart
#endif
#define UART3_PORT 			3			    
#define POWM_UART_PORT  	3				// power meter uart


typedef struct {
    void (*rx_cb)(uint8_t* data, uint16_t *len);
    // int baud_rate;
    uint8_t* rx_buf;
    uint16_t rx_buf_size;
    volatile uint16_t rx_buf_pos;
} ZqUartHandle;

extern ZqUartHandle zq_uart_handle[4];

extern void UartInit(uint8_t port, int baudrate, uint8_t *rx_buf, uint16_t rx_buf_size, void (*rx_cb)(uint8_t* data, uint16_t* len));
extern void UartSend(uint8_t port, uint8_t *buf, uint16_t len);
extern void UartRecv(uint8_t port, void (*rx_cb)(ZqCommPkg *pkg));
extern void UartLock(uint8_t port);
extern void UartUnlock(uint8_t port);
